<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>linenr</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="linen.html" title="linen" />
    <link rel="next" href="lineto.html" title="lineto" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">linenr</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="linen.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="lineto.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="linenr"></a>
      <div class="titlepage"></div>
      <a id="IndexLinenr" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">linenr</span>
        </h2>
        <p>linenr — 
      The <span class="emphasis"><em>linen</em></span> opcode extended with a final release segment.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118872048"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>linenr</em></span> -- same as <a class="link" href="linen.html" title="linen"><em class="citetitle">linen</em></a> except that the final segment is entered only on sensing a MIDI note release. The note is then extended by the decay time.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118874592"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>linenr</strong></span> xamp, irise, idec, iatdec</pre>
        <pre class="synopsis">kres <span class="command"><strong>linenr</strong></span> kamp, irise, idec, iatdec</pre>
      </div>
      <div class="refsect1">
        <a id="idp118878240"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>irise</em></span> -- rise time in seconds. A zero or negative value signifies no rise modification.
    </p>
        <p>
      <span class="emphasis"><em>idec</em></span> -- decay time in seconds. Zero means no decay. An <span class="emphasis"><em>idec</em></span> &gt; <span class="emphasis"><em>idur</em></span> will cause a truncated decay.
    </p>
        <p>
      <span class="emphasis"><em>iatdec</em></span> -- attenuation factor by which the closing steady state value is reduced exponentially over the decay period. This value must be positive and is normally of the order of .01. A large or excessively small value is apt to produce a cutoff which is audible. A zero or negative value is illegal.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118882832"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp, xamp</em></span> -- input amplitude signal.
    </p>
        <p>
      <span class="emphasis"><em>linenr</em></span> is unique within Csound in containing a <span class="emphasis"><em>note-off sensor</em></span> and <span class="emphasis"><em>release time extender</em></span>. When it senses either a score event termination or a MIDI noteoff, it will immediately extend the performance time of the current instrument by <span class="emphasis"><em>idec</em></span> seconds, then execute an exponential decay towards the factor <span class="emphasis"><em>iatdec</em></span>. For two or more units in an instrument, extension is by the greatest <span class="emphasis"><em>idec</em></span>.
    </p>
        <p>
      You can use other pre-made envelopes which start a release segment upon recieving a note off message, like <a class="link" href="linsegr.html" title="linsegr"><em class="citetitle">linsegr</em></a> and <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>, or you can construct more complex envelopes using <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> and <a class="link" href="release.html" title="release"><em class="citetitle">release</em></a>. Note that you don't need to use <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a> if you are using <span class="emphasis"><em>linenr</em></span>, since the time is extended automatically.
    </p>
        <p>
      These <span class="quote">“<span class="quote">r</span>”</span> units can also be modified by MIDI noteoff velocities (see veloffs).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118894464"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the linenr opcode. It uses the file <a class="ulink" href="examples/linenr.csd" target="_top"><em class="citetitle">linenr.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp118896320"></a>
          <p class="title">
            <strong>Example 421. Example of the linenr opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in</span>
-odac           -iadc       -M0 <span class="comment">;;;RT audio I/O with MIDI in</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="comment">; Example by Jonathan Murphy and Charles Gran 2007</span>
  <span class="ohdr">sr</span>	    <span class="op">=</span>  44100
  <span class="ohdr">ksmps</span>	    <span class="op">=</span>  10
  <span class="ohdr">nchnls</span>    <span class="op">=</span>  2

        <span class="comment">; new, and important. Make sure that midi note events are only</span>
        <span class="comment">; received by instruments that actually need them.</span>

	<span class="comment">; turn default midi routing off</span>
	<span class="ohdr">massign</span>		0, 0
	<span class="comment">; route note events on channel 1 to instr 1</span>
	<span class="ohdr">massign</span>		1, 1

<span class="comment">; Define your midi controllers</span>
<span class="omacro">#define</span> C1 #21#
<span class="omacro">#define</span> C2 #22#
<span class="omacro">#define</span> C3 #23#

<span class="comment">; Initialize MIDI controllers</span>
	    <span class="opc">initc7</span>    1, 21, 0.5 		  <span class="comment">;delay send</span>
	    <span class="opc">initc7</span>    1, 22, 0.5		  <span class="comment">;delay: time to zero</span>
	    <span class="opc">initc7</span>    1, 23, 0.5 		  <span class="comment">;delay: rate </span>

  gaosc	    <span class="opc">init</span>      0

<span class="comment">; Define an opcode to "smooth" the MIDI controller signal</span>
    <span class="oblock">opcode</span> smooth, k, <span class="opc">k</span>
  kin       <span class="opc">xin</span>
  kport	    <span class="opc">linseg</span>    0, 0.0001, 0.01, 1, 0.01
  kin       <span class="opc">portk</span>     kin, kport
            <span class="opc">xout</span>      kin
    <span class="oblock">endop</span>

<span class="oblock">instr</span>   1  
 <span class="comment">; Generate a sine wave at the frequency of the MIDI note that triggered the intrument</span>
  ifqc	    <span class="opc">cpsmidi</span>
  iamp	    <span class="opc">ampmidi</span>   10000
  aenv	    <span class="opc">linenr</span>    iamp, .01, .1, .01 	  <span class="comment">;envelope</span>
  a1	    <span class="opc">oscil</span>     aenv, ifqc, 1
<span class="comment">; All sound goes to the global variable gaosc</span>
  gaosc	    <span class="op">=</span>  gaosc <span class="op">+</span> a1
    <span class="oblock">endin</span>

    <span class="oblock">instr</span>     198 <span class="comment">; ECHO</span>
  kcmbsnd   <span class="opc">ctrl7</span>     1, 21, 0, 1 		  <span class="comment">;delay send</span>
  ktime	    <span class="opc">ctrl7</span>     1, 22, 0.01, 6 		  <span class="comment">;time loop fades out</span>
  kloop	    <span class="opc">ctrl7</span>     1, 23, 0.01, 1 		  <span class="comment">;loop speed</span>
<span class="comment">; Receive MIDI controller values and then smooth them</span>
  kcmbsnd   smooth    kcmbsnd
  ktime	    smooth    ktime
  kloop	    smooth    kloop

  imaxlpt   <span class="op">=</span>  1 				  <span class="comment">;max loop time</span>
<span class="comment">; Create a variable reverberation (delay) of the gaosc signal</span>
  acomb	    <span class="opc">vcomb</span>     gaosc, ktime, kloop, imaxlpt, 1
  aout	    <span class="op">=</span>  (acomb <span class="op">*</span> kcmbsnd) <span class="op">+</span> gaosc <span class="op">*</span> (1 <span class="op">-</span> kcmbsnd)
	    <span class="opc">outs</span>      aout, aout
  gaosc	    <span class="op">=</span>  0
    <span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1 0 16384 10 1
<span class="stamnt">i</span>198 0 10000
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118900608"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="linsegr.html" title="linsegr"><em class="citetitle">linsegr</em></a>,
      <a class="link" href="expsegr.html" title="expsegr"><em class="citetitle">expsegr</em></a>,
      <a class="link" href="envlpxr.html" title="envlpxr"><em class="citetitle">envlpxr</em></a>,
      <a class="link" href="mxadsr.html" title="mxadsr"><em class="citetitle">mxadsr</em></a>,
      <a class="link" href="madsr.html" title="madsr"><em class="citetitle">madsr</em></a>,
      <a class="link" href="envlpx.html" title="envlpx"><em class="citetitle">envlpx</em></a>,
      <a class="link" href="linen.html" title="linen"><em class="citetitle">linen</em></a>,
      <a class="link" href="xtratim.html" title="xtratim"><em class="citetitle">xtratim</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="linen.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="lineto.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">linen </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> lineto</td>
        </tr>
      </table>
    </div>
  </body>
</html>
